import axiosInstance from "@/utils/request";

/**
 * 图书信接口地址
 */
enum Api {
    BASE_URL = '/book/admin',
    PAGE_BOOK_BASE_INFO = `${BASE_URL}/pageBookBaseInfo`,
    DELETE_BOOK = `${BASE_URL}/deleteBook`,
    SELECT_ALL = `${BASE_URL}/selectAll`,
    BORROW_BOOK = `${BASE_URL}/borrowBook`,
    RETURN_BOOK = `${BASE_URL}/returnBook`,
    PAGE_BOOK_STATUS_STUDENT = `${BASE_URL}/pageBookStatusStudent`,
    PAGE_BOOK_STATUS_ADMIN = `${BASE_URL}/pageBookStatusAdmin`,
    ADMIN_AGREE_BORROW_OR_RETURN = `${BASE_URL}/adminAgreeBorrowOrReturn`,
    ADMIN_REFUSE_BORROW_OR_RETURN = `${BASE_URL}/adminRefuseBorrowOrReturn`,
}

/**
 * 分页查询图书信息
 * @param data 参数
 */
export const pageBookBaseInfoReq = (data: any) => {
    return axiosInstance({
        url: Api.PAGE_BOOK_BASE_INFO,
        method: 'post',
        data: data
    })
}

/**
 * 删除图书信息
 * @param id
 */
export const deleteBookReq = (id: string) => {
    return axiosInstance({
        url: `${Api.DELETE_BOOK}/${id}`,
        method: 'delete',
    })
}

/**
 * 查询全部图书信息
 */
export const selectAllReq = () => {
    return axiosInstance({
        url: Api.SELECT_ALL,
        method: 'get',
    })
}

/**
 * 借阅图书
 * @param params 参数
 */
export const borrowBookReq = (params: any) => {
    return axiosInstance({
        url: Api.BORROW_BOOK,
        method: 'post',
        data: params
    })
}

/**
 * 归还图书
 * @param params 参数
 */
export const returnBookReq = (params: any) => {
    return axiosInstance({
        url: Api.RETURN_BOOK,
        method: 'post',
        data: params
    })
}

/**
 * 分页查询图书状态
 * @param data 参数
 */
export const pageBookStatusStudentReq = (data: any) => {
    return axiosInstance({
        url: Api.PAGE_BOOK_STATUS_STUDENT,
        method: 'post',
        data: data
    })
}

/**
 * 分页查询图书状态
 * @param data 参数
 */
export const pageBookStatusAdminReq = (data: any) => {
    return axiosInstance({
        url: Api.PAGE_BOOK_STATUS_ADMIN,
        method: 'post',
        data: data
    })
}

/**
 * 管理员同意借阅或归还
 * @param params 参数
 */
export const adminAgreeBorrowOrReturnReq = (params: any) => {
    return axiosInstance({
        url: Api.ADMIN_AGREE_BORROW_OR_RETURN,
        method: 'post',
        data: params
    })
}

/**
 * 管理员拒绝借阅或归还
 * @param params 参数
 */
export const adminRefuseBorrowOrReturnReq = (params: any) => {
    return axiosInstance({
        url: Api.ADMIN_REFUSE_BORROW_OR_RETURN,
        method: 'post',
        data: params
    })
}
